/* GUI CONVERTED from reptrp01.p (converter v1.76) Mon Sep 17 22:18:34 2001 */
/* reptrp01.p - ITEM EFFICIENCY REPORT REPETITIVE                             */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.8.1.6 $                                                      */
/*V8:ConvertMode=FullGUIReport                                                */
/* REVISION: 5.0      LAST MODIFIED: 06/01/89   BY: emb                       */
/* REVISION: 7.3      LAST MODIFIED: 04/27/93   BY: dzs  *GA37*               */
/* REVISION: 7.4      LAST MODIFIED: 01/12/94   BY: qzl *H276*                */
/* REVISION: 7.4      LAST MODIFIED: 12/29/94   BY: cpp *FT95*                */
/* REVISION: 8.6      LAST MODIFIED: 10/15/97   BY: bvm *K0ZK*                */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.8.1.5    BY: Hualin Zhong   DATE: 06/13/01 ECO: *N0ZF*         */
/* $Revision: 1.8.1.6 $   BY: Manjusha Inglay  DATE: 08/28/01 ECO: *P01R*      */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE          */

/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE reptrp01_p_1 "Efficiency"
/* MaxLen: Comment: */

&SCOPED-DEFINE reptrp01_p_7 "Variance"
/* MaxLen: Comment: */

&SCOPED-DEFINE reptrp01_p_9 "Setup Eff"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define variable emp like op_emp.
define variable emp1 like op_emp.
define variable part like op_part.
define variable part1 like op_part.
define variable opdate like op_date.
define variable opdate1 like op_date.
define variable run_var like op_act_run column-label {&reptrp01_p_7}.
define variable run_eff as decimal format "->>>9.99%"
   column-label {&reptrp01_p_1}.
define variable setup_var like wr_setup format "->>9.999".
define variable setup_eff as decimal format "->>>9.99%"
   column-label {&reptrp01_p_9}.
define variable desc1 like pt_desc1.
define variable std_run like op_std_run format "->,>>9.999".
define variable setup_per like wr_setup.
define variable s_num as character extent 7 format "x(9)".
define variable d_num as decimal decimals 9 extent 7.
define variable i as integer.
define variable j as integer.
define variable l_item_total as character format "x(15)".
define variable l_report_total as character format "x(15)".


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
part     colon 20    part1   label {t001.i} colon 49
   opdate   colon 20    opdate1 label {t001.i} colon 49
   emp      colon 20    emp1    label {t001.i} colon 49
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

assign
   l_item_total   = getTermLabelRtColon("ITEM_TOTAL",14) + " "
   l_report_total = getTermLabelRtColon("REPORT_TOTAL",14) + " ".

{wbrp01.i}


/*GUI*/ {mfguirpa.i true "printer" 132 " " " " " "  }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:

   if emp1 = hi_char then emp1 = "".
   if part1 = hi_char then part1 = "".
   if opdate = low_date then opdate  = ?.
   if opdate1 = hi_date then opdate1 = ?.

   if c-application-mode <> 'web' then
      
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


   {wbrp06.i &command = update
             &fields = "  part part1 opdate opdate1 emp emp1"
             &frm = "a"}

   if (c-application-mode <> 'web') or
      (c-application-mode = 'web' and
      (c-web-request begins 'data')) then do:

      bcdparm = "".
      {mfquoter.i part   }
      {mfquoter.i part1  }
      {mfquoter.i opdate }
      {mfquoter.i opdate1}
      {mfquoter.i emp    }
      {mfquoter.i emp1   }

      if emp1 = "" then emp1 = hi_char.
      if part1 = "" then part1 = hi_char.
      if opdate = ?  then opdate  = low_date.
      if opdate1 = ? then opdate1 = hi_date.

   end.

   /* OUTPUT DESTINATION SELECTION */
   
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i "printer" 132 " " " " " " " " }
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:



   {mfphead.i}

   for each op_hist
   where (op_part >= part and op_part <= part1)
     and (op_date >= opdate and op_date <= opdate1)
     and (op_emp >= emp and op_emp <= emp1)
     and op_type = "LABOR"
   use-index op_part no-lock
   break by op_part by op_wo_op by op_date
   with frame b width 132 no-attr-space:

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame b:handle).

      if op_part = "" then next.

      if c-application-mode <> 'web' then
         view frame phead.

      assign
         std_run = op_std_run * op_qty_comp
         run_var = std_run - op_act_run
         run_eff = (std_run / op_act_run) * 100.

      if op_std_run = 0 then
         run_eff = 0.
      if run_eff = ? then
         run_eff = 100.

      accumulate op_qty_comp (total by op_part by op_wo_op).
      accumulate std_run (total by op_part by op_wo_op).
      accumulate op_act_run (total by op_part by op_wo_op).

      if first-of(op_wo_op) then do with frame b:
         if page-size - line-counter < 6 then
            page.
         display WITH STREAM-IO /*GUI*/ .

         put {gplblfmt.i &FUNC=getTermLabelRt(""ITEM_NUMBER"",11)
                         &CONCAT="': '"} op_part.
         find pt_mstr where pt_part = op_part no-lock no-error.
         if available pt_mstr then
            put pt_desc1 space(1) pt_desc2.

         find last ro_det no-lock
         where ro_routing = op_part
           and ro_op = op_wo_op
           and (ro_start = ? or ro_start <= opdate)
           and (ro_end = ? or ro_end >= opdate1) no-error.

         put skip {gplblfmt.i &FUNC=getTermLabelRt(""OPERATION"",11)
                              &CONCAT="': '"} string(op_wo_op).
         if available ro_det then
            put ro_desc.
         put skip(1).
      end.

      display
         space(4)
         op_date
         op_shift
         op_emp
         op_wkctr
         op_mch
         op_qty_comp
         std_run
         op_act_run
         run_var column-label {&reptrp01_p_7}
         run_eff
         space(3)
         op_trnbr format ">>>>>>>9" WITH STREAM-IO /*GUI*/ .

      if last-of(op_wo_op) then do with frame b:

         if page-size - line-counter < 2 then
            page.
         else do:
            down 1.
            underline
               op_qty_comp
               std_run
               op_act_run
               run_var column-label {&reptrp01_p_7}
               run_eff.
         end.

         down 1.

         display
            getTermLabel("OPERATION",9) @ op_wkctr format "x(9)"
            getTermLabel("TOTAL",7) + ":" @ op_mch
            accum total by op_wo_op op_qty_comp @ op_qty_comp
            accum total by op_wo_op std_run @ std_run
            accum total by op_wo_op op_act_run @ op_act_run
            (accum total by op_wo_op std_run) -
            (accum total by op_wo_op op_act_run)
            @ run_var column-label {&reptrp01_p_7}
            ((accum total by op_wo_op std_run)
            / (accum total by op_wo_op op_act_run)) * 100 @ run_eff WITH STREAM-IO /*GUI*/ .

      end.

      if last-of(op_part) then do with frame b:

         if page-size - line-counter < 2 then
            page.
         else do:
            down 1.

            underline
               std_run
               op_act_run
               run_var column-label {&reptrp01_p_7}
               run_eff.
         end.

         down 1.

         display
            l_item_total @ op_qty_comp
            accum total by op_part std_run @ std_run
            accum total by op_part op_act_run @ op_act_run
            (accum total by op_part std_run) -
            (accum total by op_part op_act_run)
            @ run_var column-label {&reptrp01_p_7}
            ((accum total by op_part std_run)
            / (accum total by op_part op_act_run)) * 100 @ run_eff WITH STREAM-IO /*GUI*/ .

      end.

      if last (op_part) then do with frame b:

         if page-size - line-counter < 2 then do with frame b:
            page.
            down 1.
         end.
         else
            down 2.

         display
            l_report_total @ op_qty_comp
            accum total std_run @ std_run
            accum total op_act_run @ op_act_run
            (accum total std_run) - (accum total op_act_run)
            @ run_var column-label {&reptrp01_p_7}
            ((accum total std_run) / (accum total op_act_run)) *
            100 @ run_eff WITH STREAM-IO /*GUI*/ .

      end.

      
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

   end.

   /* REPORT TRAILER */
   
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


end.

{wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" part part1 opdate opdate1 emp emp1 "} /*Drive the Report*/
